//-----------------------  If you're close to the next level and have energy, do the biggest mission you can
function useenergytolevel()
	{
	missionsbyexp.sort(sortbyexperience); //sorts the mission array by descending exp		
	if (location.href.indexOf(SCRIPT.name+'/jobs') != -1)
		{
		for (var i=0;i<missionsbyexp.length;i++)
			{
			
			if (energy>=missionsbyexp[i][1])
				{
				alert (missionsbyexp[i][0] + '\n' +
				missionsbyexp[i][5]);

				var mission = i;
				var jobname = missionsbyexp[mission][3];
				var currentTab = missionsbyexp[mission][2];
				//var sform = document.getElementById(SCRIPT.appID+"doJob_"+missions[mission][4]);
				var sform = document.evaluate("//form[@id='"+SCRIPT.appID+"_doJob_"+missionsbyexp[mission][4]+"']",document,null,9,null).singleNodeValue;
				//sform.submit();
				flag = 1;
				break; //drop out of for loop
				}
			}
		}
	else
		{
		window.location = "http://apps.facebook.com/"+SCRIPT.name+"/jobs.php?tab="+missions[GM_getValue('selectMission', 1)][2];
		flag = 1;
		return;
		}
	}

